# Contributor: Jake Buchholz Göktürk <tomalok@gmail.com>
# Maintainer: Jake Buchholz Göktürk <tomalok@gmail.com>
pkgname=docker-cli-buildx
_commit=6224def4dd2c3d347eee19db595348c50d7cb491
pkgver=0.8.2
pkgrel=2
pkgdesc="A Docker CLI plugin for extended build capabilities"
url="https://docs.docker.com/engine/reference/commandline/buildx_build"
arch="all"
license="Apache-2.0"
depends="docker-cli"
makedepends="go"
options="net"
source="buildx-$pkgver.tar.gz::https://github.com/docker/buildx/archive/v$pkgver.tar.gz"

_buildx_installdir="/usr/libexec/docker/cli-plugins"

builddir="$srcdir"/buildx-"$pkgver"

export GOPATH=$srcdir/go
export GOCACHE=$srcdir/go-build
export GOTMPDIR=$srcdir

build() {
	PKG=github.com/docker/buildx
	local ldflags="-X $PKG/version.Version=v$pkgver -X $PKG/version.Revision=$_commit -X $PKG/version.Package=$PKG"
	go build -modcacherw -ldflags "$ldflags" -o docker-buildx ./cmd/buildx
}

check() {
	# filecount tests are excluded because they depend on exact file sizes
	# which depend on filesystem used.
	local pkgs="$(go list -modcacherw ./... | grep -Ev '(plugins/inputs/filecount)')"
	go test -modcacherw -short $pkgs
	./docker-buildx version
}

package() {
	install -Dm755 docker-buildx "$pkgdir$_buildx_installdir"/docker-buildx
}

sha512sums="
2fe0280391d6bd4589d125e2f8a951320619d5635ce3dd0c9e06ca95e6025ab4e410a6e72e29b54a5546714a0c4c238084cdec290dfe342d739bec06681c8d4d  buildx-0.8.2.tar.gz
"
